/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package projorientado.application;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author João Neto
 */
@Entity
@Table(name = "placas_validas")
@NamedQueries({@NamedQuery(name = "PlacasValidas.findAll", query = "SELECT p FROM PlacasValidas p"), @NamedQuery(name = "PlacasValidas.findById", query = "SELECT p FROM PlacasValidas p WHERE p.id = :id"), @NamedQuery(name = "PlacasValidas.findByPlaca", query = "SELECT p FROM PlacasValidas p WHERE p.placa = :placa"), @NamedQuery(name = "PlacasValidas.findByAtiva", query = "SELECT p FROM PlacasValidas p WHERE p.ativa = :ativa")})
public class PlacasValidas implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "placa")
    private String placa;
    @Basic(optional = false)
    @Column(name = "ativa")
    private boolean ativa;
    @JoinColumn(name = "usuario", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Usuarios usuario;

    public PlacasValidas() {
    }

    public PlacasValidas(Integer id) {
        this.id = id;
    }

    public PlacasValidas(Integer id, String placa, boolean ativa) {
        this.id = id;
        this.placa = placa;
        this.ativa = ativa;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        Integer oldId = this.id;
        this.id = id;
        changeSupport.firePropertyChange("id", oldId, id);
    }

    public String getPlaca() {
        return placa;
    }

    public void setPlaca(String placa) {
        String oldPlaca = this.placa;
        this.placa = placa;
        changeSupport.firePropertyChange("placa", oldPlaca, placa);
    }

    public boolean getAtiva() {
        return ativa;
    }

    public void setAtiva(boolean ativa) {
        boolean oldAtiva = this.ativa;
        this.ativa = ativa;
        changeSupport.firePropertyChange("ativa", oldAtiva, ativa);
    }

    public Usuarios getUsuario() {
        return usuario;
    }

    public void setUsuario(Usuarios usuario) {
        Usuarios oldUsuario = this.usuario;
        this.usuario = usuario;
        changeSupport.firePropertyChange("usuario", oldUsuario, usuario);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PlacasValidas)) {
            return false;
        }
        PlacasValidas other = (PlacasValidas) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "dectordeplaca.PlacasValidas[id=" + id + "]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }

}
